﻿namespace CSharpPro._0925;

public class Demo
{
    public void Test()
    {
        Console.WriteLine("请输入一个三位数：");
        int num = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine(num/100);
        Console.WriteLine(num%100/10);
        Console.WriteLine(num%100%10);
    }

    public void Test1()
    {
        Console.WriteLine("请输入一个年份");
        int a = Convert.ToInt32(Console.ReadLine());
        Boolean tf = (a % 4 == 0 && a % 100 != 0) || (a % 400 == 0);
        Console.WriteLine(tf);
    }
    
    public class TravelCalculator
    {
        public void CalculateAndDisplayPrice()
        {
            System.Console.WriteLine("请输入月份和出行方式");
            System.Console.Write("月份：(1-12)");
            int month = int.Parse(System.Console.ReadLine());
        
            System.Console.Write("出行方式（1-航班，2-动车）：");
            int transport = int.Parse(System.Console.ReadLine());
        
            double price = CalculatePrice(month, transport);
            System.Console.WriteLine($"最终价格：{price:F2}元");
        }

        public static double CalculatePrice(int month, int transport)
        {
            double basePrice = 8800;
            double discount;
            if (month >= 5 && month <= 10)
            {
                if (transport == 1)
                {
                    discount = 0.9;
                }
                else
                {
                    discount = 0.75;
                }
            }
            else
            {
                if (transport == 1)
                {
                    discount = 0.6;
                }
                else
                {
                    discount = 0.3;
                }
            }
        
            return basePrice * discount;
        }
    }
}